package com.fat.mapper;

import com.fat.pojo.Category;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CategoryMapper {


    int insert(Category category);

    @Select("select count(*) from category where category_name=#{categoryName} and create_user=#{id}")
    int findByName(String categoryName, int id);

    @Select("select id, category_name, category_alias, create_time, update_time from category where create_user=#{id}")
    List<Category> findByCreateUser(int id);

    @Select("select id, category_name, category_alias, create_time, update_time from category where id=#{id}")
    Category findById(int id);

    int update(Category category);

    @Delete("delete from category where id=#{id}")
    int delete(int id);
}
